package com.geh.learn.completablefuture;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class CalcTest {

    public static Integer calc(Integer para) {
        try {
            Thread.sleep(5000);
        } catch (Exception e) {
        }
        return para * para;
    }
    public static void main(String[] args) throws InterruptedException, ExecutionException {
        final CompletableFuture<Integer> future = CompletableFuture.supplyAsync(() -> calc(50));
        System.out.println("先输出在等待");
        System.out.println(future.get());
        System.out.println("计算完毕以后");


    }

}
